package org.exes;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Date;

public class Serializacion {
     public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {
        FileOutputStream fos = new FileOutputStream("salida.ser");
        ObjectOutputStream oos = new ObjectOutputStream(fos);
        
        
        Date d = new Date();        
        oos.writeObject(d);
        Persona p = new Persona();        
        oos.writeObject(p);
        
        ArrayList lista = new ArrayList();
        lista.add("Prueba");
        lista.add("Prueba2");
        oos.writeObject(lista);
        
        
        oos.flush();
        oos.close();
        
        
        FileInputStream fis = new FileInputStream("salida.ser");
        ObjectInputStream ois = new ObjectInputStream(fis);
        
        
        Date fecha = (Date)ois.readObject();        
        System.out.println(fecha);

        Persona per = (Persona)ois.readObject();        
        System.out.println(per);

        ArrayList lista2 = (ArrayList)ois.readObject();        
        System.out.println(lista2);
            
        ois.close();
        
        
        
        
     }

}
